#include <unistd.h>
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/time.h>

int main(int argc, const char *argv[])
{
	tzset();
	printf("Global TZ Var::tzname %s, %s; timezone %ld\n", tzname[0], tzname[1], timezone);

	time_t now = time(NULL);
	struct timeval now_1;

	gettimeofday(&now_1, NULL);
	printf("gettimeofday tv_sec = %ld, now = %ld\n", now_1.tv_sec, now);

	struct tm now_2;
	localtime_r(&now, &now_2);
	printf("localtime: %s\n", asctime(&now_2));

	setenv("TZ", "GMT+00:00", 1);
	tzset();
	printf("[after set]Global TZ Var::tzname %s, %s; timezone %ld\n", tzname[0], tzname[1], timezone);

	localtime_r(&now, &now_2);
	printf("TZ=%s localtime: %s\n",getenv("TZ"), asctime(&now_2));

	unsetenv("TZ");
	return 0;
}
